using System;
using Voodoo.Sauce.Internal.DebugScreen;

namespace Voodoo.Sauce.Tools.AccessButton
{
	public class DebugAccessButton : DebugToggleComponent
	{
		protected override bool DefaultButtonState()
		{
			return AccessProcess.HasAccess();
		}

		public override void SetEnabled(bool isEnabled)
		{
			AccessProcess.SetAccess(isEnabled);
			base.SetEnabled(isEnabled);
		}

		private void Awake()
		{
			AccessProcess.InstantiateAccessButton = (AccessProcess.AccessButtonEvent)Delegate.Combine(AccessProcess.InstantiateAccessButton, new AccessProcess.AccessButtonEvent(base.UpdateEnabled));
			AccessProcess.DisposeAccessButton = (AccessProcess.AccessButtonEvent)Delegate.Combine(AccessProcess.DisposeAccessButton, new AccessProcess.AccessButtonEvent(base.UpdateEnabled));
		}

		private void OnDestroy()
		{
			AccessProcess.InstantiateAccessButton = (AccessProcess.AccessButtonEvent)Delegate.Remove(AccessProcess.InstantiateAccessButton, new AccessProcess.AccessButtonEvent(base.UpdateEnabled));
			AccessProcess.DisposeAccessButton = (AccessProcess.AccessButtonEvent)Delegate.Remove(AccessProcess.DisposeAccessButton, new AccessProcess.AccessButtonEvent(base.UpdateEnabled));
		}
	}
}
